package com.qiaofang.applet.service.property.service;

import com.qiaofang.applet.constants.PropertySortConstants;
import com.qiaofang.applet.service.member.domain.Employee;
import com.qiaofang.applet.service.member.service.dto.EmployeeListDto;
import com.qiaofang.applet.service.property.domain.Property;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Query;

import java.util.ArrayList;
import java.util.List;

public interface QueryCommonService {

    default void createFindSort(Query queryCriteria, Integer sort) {
        PropertySortConstants enums = PropertySortConstants.getValueByCode(sort);
        if (null != enums) {
            if (enums.getValue().contains("_desc")) {
                String field = enums.getValue().replace("_desc", "");
                queryCriteria.with(Sort.by(
                        Sort.Order.desc(field)
                ));
            }

            if (enums.getValue().contains("_asc")) {
                String field = enums.getValue().replace("_asc", "");
                queryCriteria.with(Sort.by(
                        Sort.Order.asc(field)
                ));
            }
        }
    }

}
